Page({
  data: {
    catesList: [{
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031646670.png',
      'title': '蕴实大家电',
      'tag': 1
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031649326.png',
      'title': '智能小家电',
      'tag': 2
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031642108.png',
      'title': '智能家具',
      'tag': 3
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031638335.png',
      'title': '智能防护',
      'tag': 4
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031652832.png',
      'title': 'cokiing',
      'tag': 5
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031656637.png',
      'title': '日用百货',
      'tag': 6
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031658832.png',
      'title': '个护清洁',
      'tag': 7
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031702947.png',
      'title': '生鲜食品',
      'tag': 8
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031706392.png',
      'title': '穿戴设备',
      'tag': 9
    }, {
      'image_src': 'http://api_devs.wanxikeji.cn/app/pic/20210326/20210326031709535.png',
      'title': '美妆仪器',
      'tag': 10
    }],
    imgSrc: "",
    imgHttp: "",
    animationData: {},
    images: [],
    lists1: [],
    lists2: [],
    page: 1,
    listdata: [],
    searchLoading: false, //"上拉加载"的变量，默认false，隐藏 
    searchLoadingComplete: false, //“没有数据”的变量，默认false，隐藏 
    indexArry: [],
    promotionlist: [], //推荐列表,
    tagarr: [] //球形导航tag
  },
  getgoodlist() {

    wx.getSystemInfo({
      success: (result) => {
        this.setData({
          height: result.windowHeight
        })
      },
    })
    wx.request({
      url: 'http://api_devs.wanxikeji.cn/api/goodList',
      method: "POST",
      data: {
        page: this.data.page,
        size: "10",
      },
      success: (res) => {
        console.log(res.data.data.data);
        if (res.data.data.data.length != 0) {
          if (this.data.page == 1) {
            this.data.listdata = res.data.data.data
          } else {
            this.data.listdata = [...this.data.listdata, ...res.data.data.data]
          }
          this.setData({
            list: this.data.listdata,
            searchLoading: true
          })
        } else {
          this.setData({
            searchLoading: false,  //把"上拉加载"的变量设为false，隐藏 
            searchLoadingComplete: true, //把“没有数据”设为true，显示 
          
          })

        }
      }
    })
  },

  onLoad: function () {
    //获取商品列表
    this.getgoodlist()
    wx.request({
      url: 'http://api_devs.wanxikeji.cn/api/promotionGoodList',
      method: "POST",
      success: (res) => {
        this.data.promotionlist = res.data.data.data
        console.log(this.data.promotionlist, "kk");
        this.setData({
          polist: this.data.promotionlist
        })
      }
    })
  },
  bindDownLoad: function () {
    // 请求后台，获取下一页的数据。
    this.data.page++;
    this.getgoodlist()
  },



  tocommodity() {
    console.log(1)
    wx.navigateTo({
      url: "/pages/commodity/commodity"
    })
  },



  scrollToTop() {
    this.setAction({
      scrollTop: 0
    })
  },

  tap() {
    for (let i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1],
          scrollTop: (i + 1) * 200
        })
        break
      }
    }
  },

  tapMove() {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },
  gooddetile(e) {
    wx.navigateTo({
      url: "/pages/commodity/commodity?indexArr=" + `${e.currentTarget.dataset.good_id}`
    })
    console.log(e.currentTarget.dataset.good_id);
  },

  navdetalies(e) {
    wx.setStorage({
      data: e.currentTarget.dataset.tag,
      key: 'activeNav',
      success: () => {
        wx.switchTab({
          url: "/pages/categories/categories"
        })
      },
      fail: (err) => {
        console.log("缓存存储失败", err);
      }
    })
  },

})